#include<bits/stdc++.h>
using namespace std;
#define int long long
//int arr[27];
signed main()
{
	int n;
	cin >> n;
	string s;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> s;
		for (int i = 0; i < s.length(); i++) {
			if (s[i] >= '0' && s[i] <= '9' ) {
				cnt ++;
			}
		}
		cout << cnt<<endl;
		cnt = 0;
	}

	return 0;
}
